package china.lzy.controller;

import china.lzy.entity.ResResult;
import china.lzy.entity.dto.PageDto;
import china.lzy.entity.pojo.Order;
import china.lzy.service.OrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lzy
 * @description order
 * @date 2021-08-16
 */
@RestController
@RequestMapping(value = "/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * 新增
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @RequestMapping("/insert")
    public ResResult insert(@RequestBody Order order) {
        return orderService.insert(order);
    }

    /**
     * 刪除
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @RequestMapping("/delete/{id}")
    public ResResult delete(@PathVariable int id) {
        return orderService.delete(id);
    }

    /**
     * 更新
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @RequestMapping("/update")
    public ResResult update(@RequestBody Order order) {
        return orderService.update(order);
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @RequestMapping("/load/{id}")
    public ResResult load(@PathVariable int id) {
        return orderService.load(id);
    }

    /**
     * 查询 分页查询
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @RequestMapping("/pageList")
    public ResResult pageList(@RequestBody PageDto pageDto) {
        return orderService.pageList(pageDto);
    }

}